<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\Db;
// 应用公共文件
function getRoleName($role_id){
	
	// $role_id = implode(',',$role_id);
	
	$roleName = Db::name('role')->field('role_name')->where("id in ($role_id)")->select();

	
	//将二维数组转化为一维数组
	foreach ($roleName as $key => $value) {
		$role_name[] = $value['role_name'];
	}
	// dump($role_name);
	$role_name = implode(',',$role_name);
	return $role_name;
}

function getRuleName($rule_id){
	
	// $role_id = implode(',',$role_id);
	
	$ruleName = Db::name('rule')->field('rule_name')->where("id in ($rule_id)")->select();

	
	//将二维数组转化为一维数组
	foreach ($ruleName as $key => $value) {
		$rule_name[] = $value['rule_name'];
	}
	// dump($role_name);
	$rule_name = implode(',',$rule_name);
	return $rule_name;
}

function getMajorName($major_id){
	
	// $role_id = implode(',',$role_id);
	
	$majorName = Db::name('major')->field('major_name')->where("id in ($major_id)")->select();

	
	//将二维数组转化为一维数组
	foreach ($majorName as $key => $value) {
		$major_name[] = $value['major_name'];
	}
	// dump($role_name);
	$major_name = implode(',',$major_name);
	return $major_name;
}
//全局使用 查看科目
function getSubjectName($subject_id){
	
	// $role_id = implode(',',$role_id);
	
	$subjectName = Db::name('subject')->field('subject_name')->where("id in ($subject_id)")->select();

	
	//将二维数组转化为一维数组
	foreach ($subjectName as $key => $value) {
		$subject_name[] = $value['subject_name'];
	}
	// dump($role_name);
	$subject_name = implode(',',$subject_name);
	return $subject_name;
}

function getCategoryName($category_id){
	
	// $role_id = implode(',',$role_id);
	
	$categoryName = Db::name('category')->field('name')->where("id in ($category_id)")->select();

	
	//将二维数组转化为一维数组
	foreach ($categoryName as $key => $value) {
		$category_name[] = $value['name'];
	}
	// dump($role_name);
	$category_name = implode(',',$category_name);
	return $category_name;
}

function title_sub_str($title){
	$str = '';
	$str = substr($title,0,9).'..';
	return $str;
}